<?php

/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
class storyContentBakModel extends db_help
{
    public $keyFields = 'cid';//设置主键
    public function __construct() {
        parent::__construct();
        $this->table_name = $this->table('story_content_bak');
    }
    public static function load(){
        return new self();
    }
    public function restore($id){
        $story_content = $this->table('story_content');
        $sql = 'insert into ' . $story_content . ' select * from ' . $this->table_name . ' where cid = ' . $id;
        mylog($sql, 'sql-restore');
        $bool = $this->query($sql);
        if($bool) {
            $where = array(
                'cid' => $id,
            );
            $boolbak = $this->delete($where);
            return $boolbak;
        }
        return false;
    }
}